package org.monkey.common.cbs.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;

@Slf4j
@AutoConfiguration
@ConditionalOnClass(value = DruidDataSource.class)
public class DruidDataSourceAutoConfig {

  @ConfigurationProperties(prefix = "spring.datasource")
  @Bean
  @ConditionalOnMissingBean
  public DruidDataSource druidDataSource() {
    log.info("DruidDataSource init success...");
    return new DruidDataSource();
  }
}
